package June;

import java.util.Scanner;

public class Test01ArrScore {
    public static void main(String[] args) {
        System.out.println("请输入5个数字，代表1-5号评委打分。");
        double[] arr = getScores();
        format(arr);
        double max = getMax(arr);
        double min = getMin(arr);
        System.out.println("最大值为:" + max + ";最小值为:" + min);
    }

    public static double[] getScores() {
        double[] scores = new double[5];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < scores.length; ) {
            double score=sc.nextInt();
            if (score>=0&&score<=100){
                scores[i]=score;
                i++;
            }else {
                System.out.println("输入错误,当前i为"+i);
                format(scores);
            }

        }
        return scores;
    }



    public static double getMax(double[] arr) {
        double max = 0;
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        return max;
    }

    public static double getMin(double[] arr) {
        double min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        return min;
    }

    public static void format(double[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i < arr.length - 1) {
                System.out.print(arr[i] + ",");
            } else {
                System.out.print(arr[i]);
            }
        }
        System.out.print("]");
    }
}
